package com.vhly.ddxdecompiler.dexreader.file.mixeditem;

import com.vhly.ddxdecompiler.dexreader.file.DexFile;
import com.vhly.ddxdecompiler.dexreader.file.StringIdsSection;
import com.vhly.ddxdecompiler.dexreader.io.DexInputStream;

import java.io.DataOutputStream;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: vhly
 * Date: 2009-10-15
 * Time: 12:47:53
 *
 * @author vhly[FR]
 */
public final class TypeIdItem extends IdItem {
    StringIdItem item;

    private DexFile dex;

    public TypeIdItem(DexFile dexFile) {
        dex = dexFile;
    }

    public void read(DexInputStream din) throws IOException {
        // 此index代表的是 StringIds表中 指定 utf-8字符串的索引
        index = din.readInt();
        StringIdsSection sids = dex.getStringIds();
        if (sids != null) {
            item = sids.indexOf(index);
        }
    }

    public void write(DataOutputStream dout) throws IOException {
    }

    public void setStringIdItem(StringIdItem strIdItem) {
        item = strIdItem;
    }

    public StringIdItem getItem() {
        return item;
    }
}
